17  Research sites

Today is going to be a few examples from class Group Projects

17.1 Group Project Topics of Interest

I photographed the following topic areas on the chalkboard.

PhotographTopics Topics include:

  • Agricultural Land

  • Community Gardens

  • Habitat and Biodiversity

  • Potential Future Habitat

  • Fish Passages

  • Bikeways

  • Public accessible recreational lands

17.1.1 Load libraries

── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.2     ✔ readr     2.1.4
✔ forcats   1.0.0     ✔ stringr   1.5.0
✔ ggplot2   3.4.3     ✔ tibble    3.2.1
✔ lubridate 1.9.2     ✔ tidyr     1.3.0
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
Linking to GEOS 3.11.2, GDAL 3.6.2, PROJ 9.2.0; sf_use_s2() is TRUE

17.2 Data directory

The seven .geojson files should be in your working directory, moved from dropbox as homework. If you haven’t got them there, please do that now.

Check your working directory.

[1] "C:/Dev/EA078_Fall2023"

Then check the files directory to make sure the .geosjon files are in the working directory.

17.2.1 Example 1 - Community Gardens

The first step is always to import the dataset. Let’s start with the community gardens layer from the Greenprint dataset. .geojson files are a geospatial data file format. We can use st_read() to import the data.

gardens <- st_read(dsn = 'CommunityGardens.geojson')
Reading layer `CommunityGardens' from data source 
  `C:\Dev\EA078_Fall2023\CommunityGardens.geojson' using driver `GeoJSON'
Simple feature collection with 186 features and 12 fields
Geometry type: POINT
Dimension:     XY
Bounding box:  xmin: -119.2673 ymin: 32.78017 xmax: -115.5097 ymax: 34.52903
Geodetic CRS:  WGS 84

The gardens dataset is 186 observations of 13 variables and is a Geometry type POINT. Let’s make a leaflet map with mouseover labels. Figure 17.1 shows a map of California using `leaflet’. We will start with simple markers. Figure 17.1 shows the result.

leaflet() |> 
  addTiles() |> 
  addMarkers(data = gardens)
Figure 17.1: Community gardens in Southern California

17.2.1.1 In-class exercise # 1

  • Improve the basic gardens map by including a label of the Name of the garden on mouseover.
  • Improve the basic gardens map by choosing to add a feature of your choice.

17.2.1.2 In-class exercise # 2

  • Import the FishPassages.geojson dataset
  • Make a basic markers map of Fish Passages.
  • Discuss with your neighbors what a Fish passage is and how it might be visualized effectively. What other should be added to this visualization?

17.2.2 Potential future habitats

Import the dataset FutureHabitats.geojson.

habitats <- st_read(dsn = 'FutureHabitats.geojson')
Reading layer `FutureHabitats' from data source 
  `C:\Dev\EA078_Fall2023\FutureHabitats.geojson' using driver `GeoJSON'
Simple feature collection with 3228 features and 4 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: -119.4771 ymin: 33.4595 xmax: -117.6822 ymax: 34.37547
Geodetic CRS:  WGS 84

There are 3228 features and four fields. The geometry type is MULTIPOLYGON.

Let’s make a leaflet map to see what this is.

Figure 17.2 shows the potential habitats. .

leaflet() |> 
  addTiles() |> 
  addPolygons(data = habitats)
Figure 17.2: Potential future habitats listed by California Coastal Conservancy

17.2.3 In-class exercise 3

  • Modify the visualization to change the Tile layer to something more appropriate. Use the AddProviderTiles() function.
  • The data from this layer is described at TheNatureConservancy. What does this data layer show? What might be a good addition to this visualization to highlight this data layer?

17.2.4 Biodiversity

Import the data.

biodiversity <- st_read(dsn = 'Biodiversity.geojson')
Reading layer `Biodiversity' from data source 
  `C:\Dev\EA078_Fall2023\Biodiversity.geojson' using driver `GeoJSON'
Simple feature collection with 2015 features and 6 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: -119.4784 ymin: 32.61859 xmax: -114.1312 ymax: 35.80909
Geodetic CRS:  WGS 84

This dataset has 6 fields, 2015 features, and is a MULTIPOLYGON geometry type. One of the fields is described as RANK and has a ranking. Let’s make a leaflet visualization using a Rank color palette.

First, make the color palette. This is a factor, rather than a numeric or quantile, so we use the colorFactor() function. I chose the Spectral palette but you can choose any palette you think will work.

palBD <- colorFactor(domain = biodiversity$RANK, palette = 'Spectral')

Figure 17.3 shows the areas of high and low biodiversity in SoCal. I incorporated a legend, color palette, and used the Positron Tile layer instead of OSM.

leaflet() |> 
  addProviderTiles(provider = providers$CartoDB.Positron) |> 
  addPolygons(data = biodiversity,
              color = ~palBD(RANK)) |> 
  addLegend(data = biodiversity,
            title = 'Biodiversity',
            values = ~RANK,
            pal = palBD)